package com.mvc4g.test.client;

import com.google.gwt.user.client.ui.Panel;
import com.mvc4g.client.Controller;
import com.mvc4g.client.Mvc4gStarter;
import com.mvc4g.test.client.action.ChangePageAction;
import com.mvc4g.test.client.view.PageView;
import com.mvc4g.test.client.view.RootTemplate;

public class MyMvc4gStarter implements Mvc4gStarter, Constants {
	
	private int nbViewsAndActions = 0;
	private Panel rootPanel = null;
	
	public MyMvc4gStarter(Panel rootPanel, int nbViewsAndActions){
		this.nbViewsAndActions = nbViewsAndActions;
		this.rootPanel = rootPanel;
	}

	@Override
	public void start() {
		Controller controller = new Controller();
		
		controller.addView(ROOT_TEMPLATE, new RootTemplate(rootPanel, nbViewsAndActions));
		
		for(int i=0; i<nbViewsAndActions; i++){
			controller.addAction(CHANGE_PAGE + i, new ChangePageAction(i));
			controller.addView(VIEW + i, new PageView(i));
		}

	}

}
